class SyncBailHook {
  constructor () {
    this.tasks = []
  }

  tap (name, task) {
    this.tasks.push(task)
  }

  call (...args) {
    let index = 0
    let prev = undefined
    do {
      prev = this.tasks[index++](...args)
    } while (prev === undefined && index < this.tasks.length)
    // this.tasks.forEach(task => task(...args))
  }
}

let hook = new SyncBailHook(['name'])

hook.tap('react', (name) => {
  console.log('react', name)
  return '停止'
})

hook.tap('node', (name) => {
  console.log('node', name)
})

hook.call('xyf')
